"use strict";

/**
 * @ngdoc function
 * @name jgappApp.controller:UserFeedbackCtrl
 * @description
 * # UserFeedbackCtrl
 * Controller of the jgappApp
 */
angular
  .module("jgappApp")
  .controller(
    "UserFeedbackCtrl",
    function($window, $scope, openApi, DataService, Util, $rootScope) {
      $scope.param = {};
      $scope.type = [
        {
          text: "问题反馈",
          value: 1
        },
        {
          text: "优化建议",
          value: 2
        },
        {
          text: "新功能",
          value: 3
        }
      ];
      $scope.submit = function() {
        if (!$scope.param.content) {
          Util.Toast("请填写反馈意见");
          return;
        }
        if (!$scope.param.contactWay) {
          Util.Toast("请填写联系方式");
          return;
        }
        upload($scope.param);
      };
      $scope.param.type = 1;
      var upload = function(params) {
        var deviceInfo = NativeUtil.use("getDeviceInfo");
        $scope.param.deviceModel = deviceInfo.model;
        $scope.param.clientType = deviceInfo.system;
        NativeUtil.toggleProgressDialog(1);
        DataService.getData(openApi.feedback, $scope.param).then(function(data) {
          NativeUtil.toggleProgressDialog(0);
          Util.Toast(data, {
            callback: function() {
              Util.goBack();
              NativeUtil.use("close");
              $scope.$apply();
            },
            time: 1000
          });
        });
      };
    }
  );
